<?php
/**
 * Created by PhpStorm.
 * User: yy
 * Date: 2019/6/23
 * Time: 16:19
 */

namespace app\api\controller;

use app\common\service\lastWeek\LastWeekControlAnalysisService;

# 上周小结-管控分析
class LastWeekControlAnalysis extends BaseController
{
    /**
     * 减排前预报，减排后预报，实测值
     * @author yy by 2019/6/23
     */
    public function getReduceForecast()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['start_time' => '2019-06-17', 'end_time' => '2019-06-23', 'plan_id' => '1','region_id'=>53, 'station_id' => 0, 'pollutant_name' => 'pm2.5'];
        $list  = [];
        try {
            $lastWeekControlAnalysisService = new LastWeekControlAnalysisService();
            $list                           = $lastWeekControlAnalysisService->getReduceForecast($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }

    /**
     * 减排后贡献度
     * @author yy by 2019/6/24
     */
    public function getReduceAfterContribution()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['start_time' => '2019-06-17', 'end_time' => '2019-06-23', 'plan_id' => '1','region_id'=>53, 'station_id' => 0, 'pollutant_name' => 'so2'];
        $list  = [];
        try {
            $lastWeekControlAnalysisService = new LastWeekControlAnalysisService();
            $list                           = $lastWeekControlAnalysisService->getReduceAfterContribution($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }

    /**
     * 按行业查询贡献度
     * @author yy by 2019/6/24
     * @throws \MongoDB\Driver\Exception\Exception
     */
    public function getDateIndustryContribution()
    {
        $param = $this->request->param();
        # 模拟数据
//        $param = ['look_time' => '2019-06-17', 'plan_id' => '1','region_id'=>53, 'station_id' => 1, 'pollutant_name' => 'PM2.5', 'is_industry'=>1];
        $list  = [];
        try {
            $lastWeekControlAnalysisService = new LastWeekControlAnalysisService();
            $list                           = $lastWeekControlAnalysisService->getDateIndustryContribution($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }
}